from actor import DirShootByAImage, ShootDir
from actor.walk_soldier import WalkSoldier

"""
射击类基类
"""


class ShootSoldier(WalkSoldier):
    """
    定义参数
    """
    shoot_image_width = 100
    shoot_image_height = 100

    def __init__(self, walk_image_path: str, shoot_image_path: str,
                 x: int, y: int, name: str, hp: int):
        """
        参数初始化
        :param walk_image_path: 行走战士图像
        :param shoot_image_path: 射击特性图像
        :param x: x
        :param y: y
        :param name: 名字
        :param hp: 生命值
        """
        super(ShootSoldier, self).__init__(walk_image_path, x, y, name, hp)

        self.shoot_action = DirShootByAImage(shoot_image_path, self.shoot_image_width,
                                             self.shoot_image_height, True)

    def draw(self, surface, x: int, y: int):
        """
        绘制射击图像
        :param surface:
        :param x:
        :param y:
        :return:
        """
        if self.shoot_action.shoot_dir == ShootDir.not_shoot:
            super(ShootSoldier, self).draw(surface, x, y)
        elif self.shoot_action.shoot_dir == ShootDir.down:
            image = self.shoot_action.get_image()
            surface.blit(image, (self.pos_x - x, self.pos_y - y))
            image = self.walk_action.get_image()
            surface.blit(image, (self.pos_x - x, self.pos_y - y))
        elif self.shoot_action.shoot_dir == ShootDir.up:
            image = self.shoot_action.get_image()
            surface.blit(image, (self.pos_x - x, self.pos_y - 60 - y))
            image = self.walk_action.get_image()
            surface.blit(image, (self.pos_x - x, self.pos_y - y))
        else:
            image = self.shoot_action.get_image()
            surface.blit(image, (self.pos_x - x, self.pos_y - y))

    def run(self, down_flag, key_list, obstacle_group):
        pass
